﻿using System.Configuration;

namespace Nardax.Data.Configuration
{
    public sealed class NardaxDataSection: ConfigurationSection
    {
        public const string SectionName = "nardax.data";

        private const string DefaultDatabaseConnectionPolicyNameProperty = "defaultDatabaseConnectionPolicyName";
        private const string DefaultRetryPolicyNameProperty = "defaultRetryPolicyName";
        private const string DatabaseConnectionPoliciesProperty = "databaseConnectionPolicies";
        private const string RetryPoliciesProperty = "retryPolicies";

        /// <summary>
        /// Gets or sets the name of the default general-purpose retry policy.
        /// </summary>
        [ConfigurationProperty(DefaultDatabaseConnectionPolicyNameProperty, IsRequired = true)]
        public string DefaultDatabaseConnectionPolicyName
        {
            get { return (string)base[DefaultDatabaseConnectionPolicyNameProperty]; }
            set { base[DefaultDatabaseConnectionPolicyNameProperty] = value; }
        }

        /// <summary>
        /// Gets or sets the name of the default general-purpose retry policy.
        /// </summary>
        [ConfigurationProperty(DefaultRetryPolicyNameProperty)]
        public string DefaultRetryPolicyName
        {
            get { return (string)base[DefaultRetryPolicyNameProperty]; }
            set { base[DefaultRetryPolicyNameProperty] = value; }
        }

        /// <summary>
        /// Returns a collection of database connection definitions represented by the <see cref="DatabaseConnectionPolicyElement"/> object instances.
        /// </summary>
        [ConfigurationProperty(DatabaseConnectionPoliciesProperty)]
        [ConfigurationCollection(typeof(DatabaseConnectionPolicyElement))]
        public DatabaseConnectionPolicyElementCollection DatabaseConnectionPolicies
        {
            get { return (DatabaseConnectionPolicyElementCollection)base[DatabaseConnectionPoliciesProperty]; }
        }
    }
}
